/**
 * 用户模块的数据请求
 */

import request from '@/utils/request'

// 登录的请求方法
export const login = data => {
  return request({
    url: '/v1_0/authorizations',
    method: 'post',
    data
  })
}

// 发送短信验证码
export const sendCode = mobile =>{
  return request({
    url:`/v1_0/sms/codes/${mobile}`,
    method:'get'
  })
}

// 获取用户自己的信息
export const getUser = ()=>{
  return request({
    url:`/v1_0/user`,
    method:'get',
  })
}

// 获取用户频道列表
export const getUserChannels = ()=>{
  return request({
    url:'/v1_0/user/channels'
  })
}

/**
 * 添加关注
 */
export const addFollow = userId => {
  return request({
    method: 'POST',
    url: '/v1_0/user/followings',
    data: {
      target: userId
    }
  })
}
/**
 * 取消关注
 */
export const deleteFollow = userId => {
  return request({
    method: 'DELETE',
    url: `/v1_0/user/followings/${userId}`
  })
}

/**
 * 获取用户详细资料
 */
export const getUserProfile = ()=>{
  return request({
    method:'GET',
    url:'/v1_0/user/profile'
  })
}
/**
 * 更新用户资料
 * @param {*} data 
 */
export const updateUserProfile = data=>{
  return request({
    url:'/v1_0/user/profile',
    method:'PATCH',
    data
  })
}

/**
 * 更新用户头像
 * @param {*} data 
 */
export const updateUserPhoto = data=>{
  return request({
    method:'PATCH',
    url:'/v1_0/user/photo',
    data
  })
}